/*
	Given a sorted array and a target value, return the index if the target is found. 
	If not, return the index where it would be if it were inserted in order.
*/

int searchInsert(int* nums, int numsSize, int target) {
    //the array is sorted
    int index = 0 , i;
	for(i = 0 ; i < numsSize ; i++){
		if( target > *(nums + i) ){
			index++;
		}else{
			return i;
		}
	}
	return index;
}

int main(){
	int a[] = {1,3,5,7,9};
	int index = searchInsert(a, 5, 6);
	printf("%d\n", index);
}
